﻿using BasicInformation.API.Application.Command.VehicleCommand;
using BasicInformation.Infrastructure.Iml;
using BasicInformation.Infrastructure.Interface;
using MediatR;

namespace BasicInformation.API.Application.CommandHandler.VehicleCommandHandler
{
    public class VehicleDeleteCommandHandler : IRequestHandler<VehicleDeleteCommand, int>
    {
        private readonly IVehicleRepository vehicleRepository;

        public VehicleDeleteCommandHandler(IVehicleRepository vehicleRepository)
        {
            this.vehicleRepository = vehicleRepository;
        }

        public async Task<int> Handle(VehicleDeleteCommand request, CancellationToken cancellationToken)
        {
            var info = await vehicleRepository.Get(request.Id);
            info.IsDel = true;
            return await vehicleRepository.Update(info);
        }
    }
}
